<?php
use yii\helpers\Url;

$callback = function($menu){
    $data = json_decode($menu['data'], true);
    $items = $menu['children'];
    $return = [
        'label' => $menu['name'],
        'url' => [$menu['route']],
    ];
    //处理我们的配置
    if ($data) {
        //visible
        isset($data['visible']) && $return['visible'] = $data['visible'];
        //icon
        isset($data['icon']) && $data['icon'] && $return['icon'] = $data['icon'];
        //other attribute e.g. class...
        $return['options'] = $data;
    }
    //没配置图标的显示默认图标
    (!isset($return['icon']) || !$return['icon']) && $return['icon'] = 'fa fa-circle-o';
    $items && $return['items'] = $items;
    return $return;
};
?>
<aside class="main-sidebar">
    <section class="sidebar">
        <!--<ul class="sidebar-menu">
            <li class="treeview active">
                <a href="#">
                    <i class="fa fa-gears"></i> <span>权限控制</span>
                    <i class="fa fa-angle-left pull-right"></i>
                </a>
                <ul class="treeview-menu">
                    <li><a href="<?/*=Url::toRoute(['/admin/user'])*/?>"><i class="fa fa-circle-o"></i> 用户</a></li>
                    <li><a href="<?/*=Url::toRoute(['/admin/route'])*/?>"><i class="fa fa-circle-o"></i> 路由</a></li>
                    <li><a href="<?/*=Url::toRoute(['/admin/rule'])*/?>"><i class="fa fa-circle-o"></i> 规则</a></li>
                    <li><a href="<?/*=Url::toRoute(['/admin/permission'])*/?>"><i class="fa fa-circle-o"></i> 权限</a></li>
                    <li><a href="<?/*=Url::toRoute(['/admin/role'])*/?>"><i class="fa fa-circle-o"></i> 角色</a></li>
                    <li><a href="<?/*=Url::toRoute(['/admin/assignment'])*/?>"><i class="fa fa-circle-o"></i> 分配</a></li>
                    <li><a href="<?/*=Url::toRoute(['/admin/menu'])*/?>"><i class="fa fa-circle-o"></i> 菜单</a></li>
                </ul>
            </li>
        </ul>-->
        <?php
        echo dmstr\widgets\Menu::widget(
            [
                'encodeLabels' => false,
                'options' => ['class' => 'sidebar-menu'],
                'items' => \mdm\admin\components\MenuHelper::getAssignedMenu(Yii::$app->user->id, null, $callback),
            ]
        );
        ?>

    </section>

</aside>
